<template>
  <div>
<!--    基地-->
    <template>
      <el-dialog
        v-drag
        :close-on-click-modal="true"
        append-to-body width="60%"
        height="600px" title="基地"
        :visible.sync="wfzbase.show">
        <el-container>
          <el-main>
            <el-form :model="wfzbase.queryParams" ref="queryWfzbaseForm" size="small" :inline="true"
                     label-width="auto">
              <el-form-item>
                <el-form-item label="名称" prop="fname">
                  <el-input
                    v-model="wfzbase.queryParams.fname"
                    placeholder="请输入名称"
                    clearable
                    @keyup.enter.native="handleQuery_wfzbase"
                  />
                </el-form-item>
                <el-form-item label="编码" prop="fnumber">
                  <el-input
                    v-model="wfzbase.queryParams.fnumber"
                    placeholder="请输入编码"
                    clearable
                    @keyup.enter.native="handleQuery_wfzbase"
                  />
                </el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery_wfzbase">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery_wfzbase">重置</el-button>
              </el-form-item>
            </el-form>

            <el-table v-loading="wfzbase.loading"
                      :data="wfzbase.rowList"
                      ref="wfzbaseTable"
                      :row-class-name="rowBillHeadIndex"
                      @row-click="rowClick_wfzbase"
                      @row-dblclick="rowDoubleClick_wfzbase"
                      @selection-change="handleSelectionChange_wfzbase"
                      border
                      stripe
            >
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="名称" align="center" prop="fname" />
              <el-table-column label="编码" align="center" prop="fnumber" />
              <el-table-column label="描述" align="center" prop="fdescription" />
              <el-table-column label="简称" align="center" prop="fsimplename" />
              <el-table-column label="创建人" align="center" prop="fcreatorid" />
            </el-table>

            <pagination
              v-show="wfzbase.total>0"
              :total="wfzbase.total"
              :page.sync="wfzbase.queryParams.pageNum"
              :limit.sync="wfzbase.queryParams.pageSize"
              @pagination="getList_wfzbase"
            />

          </el-main>
        </el-container>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="toParentPage_wfzbase">确 定</el-button>
            <el-button @click="wfzbase.show = false">取 消</el-button>
        </span>
      </el-dialog>
    </template>
    <!--    物料BOM-->
    <template>
      <el-dialog
        v-drag
        :close-on-click-modal="true"
        append-to-body width="60%"
        height="600px" title="物料BOM"
        :visible.sync="materialhalf.show">

      <el-container>
        <el-main>
        <el-form :model="materialhalf.queryParams" ref="queryMaterialhalfForm" size="small" :inline="true" label-width="auto">
          <el-form-item label="物料BOM编码" prop="cfmaterialnumber">
            <el-input
              v-model="materialhalf.queryParams.cfmaterialnumber"
              placeholder="请输入物料BOM编码"
              clearable
              @keyup.enter.native="handleQuery_materialhalf"
            />
          </el-form-item>
          <el-form-item label="物料BOM名称" prop="cfmaterialname">
            <el-input
              v-model="materialhalf.queryParams.cfmaterialname"
              placeholder="请输入物料BOM名称"
              clearable
              @keyup.enter.native="handleQuery_materialhalf"
            />
          </el-form-item>
          <el-form-item label="是否手工新增" prop="cfverson" label-width="100px">
            <el-select v-model="materialhalf.queryParams.cfverson" placeholder="请选择是否手工新增" clearable>
              <el-option
                v-for="dict in dict.type.yes_no"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery_materialhalf">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery_materialhalf">重置</el-button>
          </el-form-item>
        </el-form>
        <el-table v-loading="materialhalf.loading"
                  :data="materialhalf.rowList"
                  ref="materialhalfTable"
                  :row-class-name="rowBillHeadIndex"
                  @row-click="rowClick_materialhalf"
                  @row-dblclick="rowDoubleClick_materialhalf"
                  @selection-change="handleSelectionChange_materialhalf"
                  border
                  stripe
        >
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="物料BOM编码" align="center" prop="cfmaterialnumber" />
          <el-table-column label="物料BOM名称" align="center" prop="cfmaterialname" />
          <el-table-column label="计量单位" align="center" prop="cfmaterialunit" />
<!--          <el-table-column label="物料BOM规格型号" align="center" prop="cfmaterialspecification" />-->
          <el-table-column label="生产量" align="center" prop="cfproductionquantity" />
        </el-table>

        <pagination
          v-show="materialhalf.total>0"
          :total="materialhalf.total"
          :page.sync="materialhalf.queryParams.pageNum"
          :limit.sync="materialhalf.queryParams.pageSize"
          @pagination="getList_materialhalf"
        />
        </el-main>
      </el-container>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="toParentPage_materialhalf">确 定</el-button>
            <el-button @click="materialhalf.show = false">取 消</el-button>
        </span>
        </el-dialog>
    </template>
    <!--    成本测算详情界面-->
    <template>
      <el-dialog
        v-drag
        :close-on-click-modal="true"
        append-to-body width="1500px"
        height="600px" title="成本测算"
        :visible.sync="basedatadialog.costcalc.show">

        <el-container>
          <el-main>
            <el-form ref="form" :model="basedatadialog.costcalc.data"  label-width="120px">
              <el-row>
                <el-col :span="8">
                  <el-form-item label="单据编码" prop="number">
                    <el-input v-model="basedatadialog.costcalc.data.number" placeholder="请输入单据编码" />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="客户" prop="cfcustomerid">
                    <el-input v-model="basedatadialog.costcalc.data.cfcustomerid" placeholder="请输入客户" />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="产品代码" prop="cfmaterialid">
                    <el-input v-model="basedatadialog.costcalc.data.cfmaterialid" placeholder="请输入产品代码" />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="产品名称" prop="cfmaterialname">
                    <el-input v-model="basedatadialog.costcalc.data.cfmaterialname" placeholder="请输入产品名称" />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="计量单位" prop="cfbaseunit">
                    <el-input v-model="basedatadialog.costcalc.data.cfbaseunit" placeholder="请输入计量单位" />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="业务日期" prop="fbizdate">
                    <el-date-picker clearable
                                    v-model="basedatadialog.costcalc.data.fbizdate"
                                    type="date"
                                    style="width: 190.67px"
                                    value-format="yyyy-MM-dd"
                                    placeholder="请选择业务日期">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="规格" prop="cfmodel">
                    <el-input v-model="basedatadialog.costcalc.data.cfmodel" placeholder="请输入规格" />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="税率" prop="cftaxrate">
                    <el-input v-model="basedatadialog.costcalc.data.cftaxrate" placeholder="请输入税率" />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="合计材料成本" prop="cftotalmaterialcost" >
                    <el-input v-model="basedatadialog.costcalc.data.cftotalmaterialcost" placeholder="请输入合计材料成本" disabled readonly />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="变动费用" prop="cfalterationfee" >
                    <el-input v-model="basedatadialog.costcalc.data.cfalterationfee" placeholder="请输入变动费用" disabled readonly/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="固定费用" prop="cffixedfee" >
                    <el-input v-model="basedatadialog.costcalc.data.cffixedfee" placeholder="请输入固定费用" disabled readonly/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="包装成本" prop="cfpackcost">
                    <el-input v-model="basedatadialog.costcalc.data.cfpackcost" placeholder="请输入包装成本" />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="合计成本" prop="cftotalcost">
                    <el-input v-model="basedatadialog.costcalc.data.cftotalcost" placeholder="请输入合计成本" disabled readonly/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="含税成本" prop="cftaxcost" >
                    <el-input v-model="basedatadialog.costcalc.data.cftaxcost" placeholder="请输入含税成本" disabled readonly />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="状态" prop="cfstate" >
                    <el-select v-model="basedatadialog.costcalc.data.cfstate" placeholder="请选择单据状态" disabled readonly clearable>
                      <el-option
                        v-for="dict in dict.type.bill_state"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="时间类型" prop="cfseasontypeid">
                    <el-select v-model="basedatadialog.costcalc.data.cfseasontypeid" placeholder="请选择时间类型" clearable>
                      <el-option
                        v-for="dict in dict.type.bom_seasontype"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="基地" prop="cfwfzbaseid">
                    <el-select v-model="basedatadialog.costcalc.data.cfwfzbaseid" placeholder="请选择基地" clearable>
                      <el-option
                        v-for="dict in dict.type.bom_wfzbase"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="是否进入产品库" prop="ffivouchered">
                    <el-select v-model="basedatadialog.costcalc.data.ffivouchered" placeholder="请选择是否进入产品库" clearable>
                      <el-option
                        v-for="dict in dict.type.yes_no"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="项目" prop="cfprojecttxt">
                    <el-input v-model="basedatadialog.costcalc.data.cfprojecttxt" placeholder="请输入项目" />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="提交部门" prop="deptName">
                    <el-input v-model="basedatadialog.costcalc.data.deptName" placeholder="请输入提交部门" readonly/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="品类" prop="fdescription">
                    <el-select v-model="basedatadialog.costcalc.data.fdescription" placeholder="请选择品类" clearable>
                      <el-option
                        v-for="dict in dict.type.bom_usercategory"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="备注" prop="cfremarktxt">
                    <el-input v-model="basedatadialog.costcalc.data.cfremarktxt" placeholder="请输入备注" />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-divider content-position="center">{{basedatadialog.costcalc.entryParameter.entryName}}</el-divider>
              <el-row :gutter="10" class="mb8" v-show="basedatadialog.costcalc.entryParameter.entry1Show">
                <el-col :span="1.5">
                  <el-button
                    type="info"
                    plain
                    icon="el-icon-sort"
                    size="mini"
                    @click="toggleExpandAll"
                  >展开/折叠</el-button>
                </el-col>
                <el-col :span="1.5" style="float: right">
                  <el-button type="primary" size="mini"
                             @click="showEntryAmount"
                  >费用
                  </el-button>
                </el-col>
                <el-col :span="1.5" style="float: right">
                  <el-button type="primary" size="mini"
                             @click="showEntryMaterial"
                             style="border:none;background-color: #FF4D09"
                  >原材料
                  </el-button>
                </el-col>
              </el-row>
              <el-table  :data="basedatadialog.costcalc.bomCostcalcentryList"
                        :row-class-name="rowBomCostcalcentryIndex"
                        ref="bomCostcalcentry"
                        v-show="basedatadialog.costcalc.entryParameter.entry1Show"
                        :indent="10"
                         max-height="800px"
                        v-loading="basedatadialog.costcalc.entryloading"
                        v-if="basedatadialog.costcalc.refreshTable"
                        :default-expand-all="basedatadialog.costcalc.isExpandAll"
                        :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                        row-key="cfbomcostcalcentryid"
              >
                <el-table-column type="selection" width="50" align="center" />
                <el-table-column label="序号" align="left" prop="index" :width="basedatadialog.costcalc.indexColumnWidth"/>
                <el-table-column label="数据来源" prop="cfbomcostcalcnumbe" width="150">
                  <template slot-scope="scope">
                    <el-select v-model="scope.row.cfbomcostcalcnumbe" placeholder="请选择数据来源" clearable :disabled="isHisCbcs(scope.row)">
                      <el-option
                        v-for="dict in dict.type.bom_materialsourse"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      />
                    </el-select>
                  </template>
                </el-table-column>
                <el-table-column label="物料编码" prop="cfmaterialhalfnumb" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfmaterialhalfnumb" placeholder="请输入物料BOM编码" :disabled="isHisCbcs(scope.row)" readonly/>
                    <span class="el-input__suffix">
                <span class="el-input__suffix-inner">
                  <i class="el-input_icon icon el-icon-search"
                     onmousemove="this.style.color='#366EDD'"
                     onmouseout="this.style.color='#919191'"
                     style="font-size: 16px;
                            position: absolute;
                            cursor: pointer;
                            right: 6px;
                            top: 20px;
                            background-color: #ffffff;"
                     @click="openF7('material',true,scope.row)"
                  />
                </span>
              </span>
                  </template>
                </el-table-column>
                <el-table-column label="物料名称" prop="cfmaterialhalfname" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfmaterialhalfname" placeholder="请输入物料BOM名称" :disabled="isHisCbcs(scope.row)" disabled/>
                  </template>
                </el-table-column>
                <!--          <el-table-column label="父编码" prop="cfrawmaterialnumbe" width="650">-->
                <!--            <template slot-scope="scope">-->
                <!--              <el-input v-model="scope.row.cfrawmaterialnumbe" placeholder="请输入物料BOM编码" :disabled="isHisCbcs(scope.row)" readonly/>-->
                <!--            </template>-->
                <!--          </el-table-column>-->
                <!--          <el-table-column label="长编码" prop="cfbomcostcalcentryid" width="650">-->
                <!--            <template slot-scope="scope">-->
                <!--              <el-input v-model="scope.row.cfbomcostcalcentryid" placeholder="请输入物料BOM编码" :disabled="isHisCbcs(scope.row)"/>-->
                <!--            </template>-->
                <!--          </el-table-column>-->
                <el-table-column label="分类编码" prop="cfrawmaterialid" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfrawmaterialid" placeholder="请输入物料BOM编码" :disabled="isHisCbcs(scope.row)"/>
                  </template>
                </el-table-column>
                <el-table-column label="单位" prop="cfmaterialhalfunit" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfmaterialhalfunit" placeholder="请输入物料BOM计量单位" :disabled="isHisCbcs(scope.row)" disabled/>
                  </template>
                </el-table-column>
                <el-table-column label="用量" prop="cfmaterialhalfdose" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfmaterialhalfdose" placeholder="请输入物料BOM用量" :disabled="isHisCbcs(scope.row)"/>
                  </template>
                </el-table-column>
<!--                <el-table-column label="初始用量" prop="cfdose" width="150">-->
<!--                  <template slot-scope="scope">-->
<!--                    <el-input v-model="scope.row.cfdose" placeholder="请输入初始用量" :disabled="isHisCbcs(scope.row)"/>-->
<!--                  </template>-->
<!--                </el-table-column>-->
                <el-table-column label="税率" prop="cftaxrate" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cftaxrate" placeholder="请输入税率" disabled/>
                  </template>
                </el-table-column>
                <el-table-column label="含税单价" prop="cftaxprice" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cftaxprice" placeholder="请输入含税价"
                              onkeyup="this.value=this.value.match(/\d+\.?\d{0,6}/);"
                              :disabled="isHisCbcs(scope.row)"
                             />
                  </template>
                </el-table-column>
                <el-table-column label="去税金额" prop="cfnotaxsum" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfnotaxsum" placeholder="请输入去税金额" :disabled="isHisCbcs(scope.row)" disabled/>
                  </template>
                </el-table-column>
              </el-table>
              <el-row :gutter="10" class="mb8" v-show="basedatadialog.costcalc.entryParameter.entry2Show">
                <el-col :span="1.5">
                  <el-button
                    type="info"
                    plain
                    icon="el-icon-sort"
                    size="mini"
                    @click="toggleExpandAll"
                  >展开/折叠</el-button>
                </el-col>
                <el-col :span="1.5" style="float: right">
                  <el-button type="primary" size="mini"
                             @click="showEntryAmount"
                             style="border:none;background-color: #ff4d09"
                  >费用
                  </el-button>
                </el-col>
                <el-col :span="1.5" style="float: right">
                  <el-button type="primary" size="mini"
                             @click="showEntryMaterial"
                  >原材料
                  </el-button>
                </el-col>
              </el-row>
              <el-table :data="basedatadialog.costcalc.bomCostcalcentryList2"
                        :row-class-name="rowBomCostcalcentryIndex"
                        ref="bomCostcalcentry2"
                        v-show="basedatadialog.costcalc.entryParameter.entry2Show"
                        :indent="10"
                        v-loading="basedatadialog.costcalc.entryloading"
                        v-if="basedatadialog.costcalc.refreshTable"
                        :default-expand-all="basedatadialog.costcalc.isExpandAll"
                        :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                        row-key="cfbomcostcalcentryid"
              >
                <el-table-column type="selection" width="50" align="center" />
                <el-table-column label="序号" align="left" prop="index" :width="basedatadialog.costcalc.indexColumnWidth"/>
                <el-table-column label="物料编码" prop="cfmaterialhalfnumb" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfmaterialhalfnumb" placeholder="请输入物料BOM编码" :disabled="isHisCbcs(scope.row)" readonly/>
                  </template>
                </el-table-column>
                <el-table-column label="物料名称" prop="cfmaterialhalfname" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfmaterialhalfname" placeholder="请输入物料BOM名称" :disabled="isHisCbcs(scope.row)" disabled/>
                  </template>
                </el-table-column>
                <el-table-column label="单位" prop="cfmaterialhalfunit" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfmaterialhalfunit" placeholder="请输入物料BOM计量单位" disabled/>
                  </template>
                </el-table-column>
                <el-table-column label="用量" prop="cfmaterialhalfdose" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfmaterialhalfdose" placeholder="请输入物料BOM用量" :disabled="isHisCbcs(scope.row)"/>
                  </template>
                </el-table-column>
                <el-table-column label="类别" prop="cfcategoryname" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfcategoryname" placeholder="请输入类别" :disabled="isHisCbcs(scope.row)" />
                    <span class="el-input__suffix">
                <span class="el-input__suffix-inner">
                  <i class="el-input_icon icon el-icon-search"
                     onmousemove="this.style.color='#366EDD'"
                     onmouseout="this.style.color='#919191'"
                     style="font-size: 16px;
                            position: absolute;
                            cursor: pointer;
                            right: 6px;
                            top: 20px;
                            background-color: #ffffff;"
                     @click="openF7('category',true,scope.row)"
                  />
                </span>
              </span>
                  </template>
                </el-table-column>
                <el-table-column label="车间" prop="cfworkshopname" width="150">
                  <template slot-scope="scope">
                    <el-select v-model="scope.row.cfworkshopname" placeholder="车间" :disabled="isHisCbcs(scope.row)" clearable>
                      <el-option
                        v-for="dict in dict.type.bom_plant"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      />
                    </el-select>
                  </template>
                </el-table-column>
                <el-table-column label="变动费用小计" prop="cfchangefee" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfchangefee" placeholder="请输入变动费用小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="固定费用小计" prop="cffixationfee" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cffixationfee" placeholder="请输入固定费用额" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="人工变动(工序)" prop="cfrgbd" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfrgbd" placeholder="请输入人工变动(工序)" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="人工变动小计" prop="cfrgbdxj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfrgbdxj" placeholder="请输入人工变动小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="人工固定(共耗)" prop="cfrggd" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfrggd" placeholder="请输入人工固定(共耗)" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="人工固定小计" prop="cfrggdxj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfrggdxj" placeholder="请输入人工固定小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="水变动(直接)" prop="cfsbd" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfsbd" placeholder="请输入水变动(直接)" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="水变动小计" prop="cfsbdxj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfsbdxj" placeholder="请输入水变动小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="水固定(共耗)" prop="cfsgd" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfsgd" placeholder="请输入水固定(共耗)" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="水固定小计" prop="cfsgdxj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfsgdxj" placeholder="请输入水固定小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="电变动(直接)" prop="cfdbd" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfdbd" placeholder="请输入电变动(直接)"  :disabled="isHisCbcs(scope.row)"/>
                  </template>
                </el-table-column>
                <el-table-column label="电变动小计" prop="cfdbdxj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfdbdxj" placeholder="请输入电变动小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="电固定(共耗)" prop="cfdgd" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfdgd" placeholder="请输入电固定(共耗)" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="电固定小计" prop="cfdgdxj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfdgdxj" placeholder="请输入电固定小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="气变动(直接)" prop="cfqbd" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfqbd" placeholder="请输入气变动(直接)" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="气变动小计" prop="cfqbdxj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfqbdxj" placeholder="请输入气变动小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="气固定(共耗)" prop="cfqgd" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfqgd" placeholder="请输入气固定(共耗)" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="气固定小计" prop="cfqgdxj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfqgdxj" placeholder="请输入气固定小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="折旧变动(专用)" prop="cfzjbd" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfzjbd" placeholder="请输入折旧变动(专用)" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="折旧变动小计" prop="cfzjbdxj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfzjbdxj" placeholder="请输入折旧变动小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="折旧固定(共耗)" prop="cfzjgd" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfzjgd" placeholder="请输入折旧固定(共耗)" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="折旧固定小计" prop="cfzjgdxj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfzjgdxj" placeholder="请输入折旧固定小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="其他变动(共耗)" prop="cfqtbd" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfqtbd" placeholder="请输入其他变动(共耗)" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="其他变动小计" prop="cfqtbdxj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfqtbdxj" placeholder="请输入其他变动小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="其他固定(共耗)" prop="cfqtgd" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfqtgd" placeholder="请输入其他固定(共耗)" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="其他固定小计" prop="cfqtgdxj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfqtgdxj" placeholder="请输入其他固定小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="额定额" prop="cfede" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfede" placeholder="请输入额定额" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column label="额定额小计" prop="cfedexj" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfedexj" placeholder="请输入额定额小计" :disabled="isHisCbcs(scope.row)" />
                  </template>
                </el-table-column>
              </el-table>
            </el-form>
          </el-main>
        </el-container>
      </el-dialog>
    </template>
    <!--    测算需求详情界面-->
    <template>
      <el-dialog
        v-drag
        :close-on-click-modal="true"
        append-to-body width="1500px"
        height="600px" title="测算需求"
        :visible.sync="calcdemand.show">

        <el-container>
          <el-main>
            <el-form ref="form" :model="calcdemand.data" label-width="120px">
              <el-row>
                <el-col :span="8">
                  <el-form-item label="单据编码" prop="number">
                    <el-input v-model="calcdemand.data.number" placeholder="请输入单据编码" disabled/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="客户编码" prop="fcustomernumber">
                    <el-input v-model="calcdemand.data.fcustomernumber" placeholder="请输入客户名称"/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="客户名称" prop="fcustomername">
                    <el-input v-model="calcdemand.data.fcustomername" placeholder="请输入客户名称"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="产品编码" prop="fmaterialnumber">
                    <el-input v-model="calcdemand.data.fmaterialnumber" placeholder="请选择物料"/>
                    <span class="el-input__suffix">
                <span class="el-input__suffix-inner">
                  <i class="el-input_icon icon el-icon-search"
                     onmousemove="this.style.color='#366EDD'"
                     onmouseout="this.style.color='#919191'"
                     style="font-size: 16px;
                            position: absolute;
                            cursor: pointer;
                            right: 6px;
                            top: 10px;
                            background-color: #ffffff;"
                     @click="openF7('specialmaterial',false,false,null)"
                  />
                </span>
            </span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="产品名称" prop="fmaterialname">
                    <el-input v-model="calcdemand.data.fmaterialname" placeholder="请输入产品名称" :disabled="calcdemand.data.fmaterialid!=null&&calcdemand.data.fmaterialid!=''"/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="规格" prop="fmodule" >
                    <el-input v-model="calcdemand.data.fmodule"  placeholder="请输入规格"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="单位" prop="fheadquartersnumber">
                    <el-input v-model="calcdemand.data.fheadquartersnumber"  placeholder="请输入单位"/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="箱规" prop="boxgauge">
                    <el-input v-model="calcdemand.data.boxgauge"  placeholder="请输入箱规"/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="税率" prop="taxrate">
                    <el-input v-model="calcdemand.data.taxrate"  placeholder="请输入税率"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="提交部门" prop="fsubmitdept">
                    <el-input v-model="calcdemand.data.fsubmitdept" placeholder="请输入提交部门"/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="联系人" prop="fcontacts">
                    <el-input v-model="calcdemand.data.fcontacts" placeholder="请输入联系人"/>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="联系电话" prop="fcontactnumber">
                    <el-input v-model="calcdemand.data.fcontactnumber" placeholder="请输入联系电话"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="时间类型" prop="cfseasontypeid">
                    <el-select v-model="calcdemand.data.cfseasontypeid" placeholder="请选择时间类型" clearable>
                      <el-option
                        v-for="dict in dict.type.bom_seasontype"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="基地" prop="cfwfzbaseid">
                    <el-select v-model="calcdemand.data.cfwfzbaseid" placeholder="请选择基地" clearable>
                      <el-option
                        v-for="dict in dict.type.bom_wfzbase"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="制单日期" prop="fcreatetime" disabled>
                    <el-date-picker clearable
                                    v-model="calcdemand.data.fcreatetime"
                                    type="date"
                                    value-format="yyyy-MM-dd"
                                    placeholder="请选择制单日期">
                    </el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="状态" prop="cfstate" >
                    <el-select v-model="calcdemand.data.cfstate" placeholder="请选择单据状态" disabled style="width: 366.67px" readonly clearable>
                      <el-option
                        v-for="dict in dict.type.bill_state"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="品类" prop="fcustomizedproducttype" >
                    <el-select v-model="calcdemand.data.fcustomizedproducttype" placeholder="请选择品类" style="width: 366.67px" clearable>
                      <el-option
                        v-for="dict in dict.type.bom_usercategory"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="备注" prop="remark">
                    <el-input v-model="calcdemand.data.remark" placeholder="请选择备注"/>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-divider content-position="center">测试需求单维护分录信息</el-divider>
              <el-table :data="calcdemand.bomCalcdemandentryList" :row-class-name="rowBomCalcdemandIndex"
                        ref="bomCalcdemandentry">
                <el-table-column type="selection" width="50" align="center"/>
                <el-table-column label="序号" align="center" prop="index" width="50"/>
                <el-table-column label="类别" prop="cfcategory" width="150">
                  <template slot-scope="scope">
                    <el-select v-model="scope.row.cfcategory" placeholder="无" clearable>
                      <el-option
                        v-for="dict in dict.type.bom_csxq_type"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                      />
                    </el-select>
                  </template>
                </el-table-column>
                <el-table-column label="产品代码" prop="cfproductcode" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfproductcode" placeholder="请输入产品代码" readonly/>
                    <span class="el-input__suffix">
                <span class="el-input__suffix-inner">
                  <i class="el-input_icon icon el-icon-search"
                     onmousemove="this.style.color='#366EDD'"
                     onmouseout="this.style.color='#919191'"
                     style="font-size: 16px;
                            position: absolute;
                            cursor: pointer;
                            right: 6px;
                            top: 15px;
                            background-color: #ffffff;"
                     @click="openF7('specialmaterial',true,false,scope.row,true)"
                  />
                </span>
            </span>
                  </template>
                </el-table-column>
                <el-table-column label="产品名称" prop="cfproductname" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfproductname" placeholder="请输入产品名称" disabled/>
                  </template>
                </el-table-column>
                <el-table-column label="产品单位" prop="cfproductunit" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfproductunit" placeholder="请输入产品单位" disabled/>
                  </template>
                </el-table-column>
                <el-table-column label="规格" prop="cfboxcode" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfboxcode" placeholder="请输入规格"  :disabled="scope.row.cfcategory=='0'"/>
                  </template>
                </el-table-column>
<!--                <el-table-column label="单品箱规" prop="cfsingleboxgauge" width="150">-->
<!--                  <template slot-scope="scope">-->
<!--                    <el-input v-model="scope.row.cfsingleboxgauge" placeholder="请输入单品箱规" disabled/>-->
<!--                  </template>-->
<!--                </el-table-column>-->
<!--                <el-table-column label="折只数" prop="cffoldnumber" width="150">-->
<!--                  <template slot-scope="scope">-->
<!--                    <el-input v-model="scope.row.cffoldnumber" placeholder="请输入折只数" disabled @change="sumListAmount(scope.row)"/>-->
<!--                  </template>-->
<!--                </el-table-column>-->
                <el-table-column label="内配数量" prop="cfquotecount" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfquotecount" placeholder="请输入内配数量" @change="sumListAmount(scope.row)"/>
                  </template>
                </el-table-column>
                <el-table-column label="备注" prop="remark" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.remark" placeholder="请输入备注"/>
                  </template>
                </el-table-column>
                <el-table-column label="合计材料成本" v-if="false" prop="cftotalmaterialcost" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cftotalmaterialcost" placeholder="请输入合计材料成本" disabled/>
                  </template>
                </el-table-column>
                <el-table-column label="合计成本" v-if="false" prop="cftotalcost" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cftotalcost" placeholder="请输入合计成本" disabled/>
                  </template>
                </el-table-column>
                <el-table-column label="含税成本" v-if="false" prop="cftaxcost" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cftaxcost" placeholder="请输入含税成本" disabled/>
                  </template>
                </el-table-column>
                <el-table-column label="包装成本" v-if="false" prop="cfpackcost" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfpackcost" placeholder="请输入包装成本" disabled/>
                  </template>
                </el-table-column>
                <el-table-column label="变动费用" v-if="false" prop="cfalterationfee" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cfalterationfee" placeholder="请输入变动费用" disabled/>
                  </template>
                </el-table-column>
                <el-table-column label="固定费用" v-if="false" prop="cffixedfee" width="150">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.cffixedfee" placeholder="请输入固定费用" disabled/>
                  </template>
                </el-table-column>
              </el-table>
              <el-divider v-if="false" content-position="center">合计行</el-divider>
              <el-table v-if="false" :data="calcdemand.bomCalcdemandentryListSumAmount" ref="bomCalcdemandentrySum">
                <el-table-column label="合计材料成本" prop="cftotalmaterialcost" width="150">
                </el-table-column>
                <el-table-column label="合计成本" prop="cftotalcost" width="150">
                </el-table-column>
                <el-table-column label="含税成本" prop="cftaxcost" width="150">
                </el-table-column>
                <el-table-column label="包装成本" prop="cfpackcost" width="150">
                </el-table-column>
                <el-table-column label="变动费用" prop="cfalterationfee" width="150">
                </el-table-column>
                <el-table-column label="固定费用" prop="cffixedfee" width="150">
                </el-table-column>
                <el-table-column label="" prop="cffixedfee" style="width: 1px">
                  <template slot-scope="scope" style="width: 1px">
                    <el-input v-model="scope.row.cffixedfee" STYLE="width:1px;visibility: hidden"/>
                  </template>
                </el-table-column>
              </el-table>
            </el-form>
          </el-main>
        </el-container>
      </el-dialog>
    </template>
    <!--    类别-->
    <template>
      <el-dialog
        v-drag
        :close-on-click-modal="true"
        append-to-body width="60%"
        height="600px" title="类别"
        :visible.sync="category.show">
        <el-container>
          <el-main>
            <el-form :model="category.queryParams" ref="queryCategoryForm" size="small" :inline="true"
                     label-width="auto">
              <el-form-item>
                <el-form-item label="编码" prop="number">
                  <el-input
                    v-model="category.queryParams.number"
                    placeholder="请输入编码"
                    clearable
                    @keyup.enter.native="handleQuery_category"
                  />
                </el-form-item>
                <el-form-item label="名称" prop="name">
                  <el-input
                    v-model="category.queryParams.name"
                    placeholder="请输入名称"
                    clearable
                    @keyup.enter.native="handleQuery_category"
                  />
                </el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery_category">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery_category">重置</el-button>
              </el-form-item>
            </el-form>

            <el-table v-loading="category.loading"
                      :data="category.rowList"
                      ref="categoryTable"
                      :row-class-name="rowBillHeadIndex"
                      @row-click="rowClick_category"
                      @row-dblclick="rowDoubleClick_category"
                      @selection-change="handleSelectionChange_category"
                      border
                      stripe
            >
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="编码" align="center" prop="number" />
              <el-table-column label="名称" align="center" prop="name" />
            </el-table>

            <pagination
              v-show="category.total>0"
              :total="category.total"
              :page.sync="category.queryParams.pageNum"
              :limit.sync="category.queryParams.pageSize"
              @pagination="getList_category"
            />

          </el-main>
        </el-container>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="toParentPage_category">确 定</el-button>
            <el-button @click="category.show = false">取 消</el-button>
        </span>
      </el-dialog>
    </template>
    <!--    特殊物料-->
    <template>
      <el-dialog
        v-drag
        :close-on-click-modal="true"
        append-to-body width="70%"
        height="600px" title="物料"
        :visible.sync="specialmaterial.show">
        <el-container>
          <el-main>
            <el-form :model="specialmaterial.queryParams" ref="querySpecialMaterialForm" size="small" :inline="true"
                     label-width="auto">
              <el-form-item>
                <el-form-item label="物料编码" prop="materialnumber">
                  <el-input
                    v-model="specialmaterial.queryParams.materialnumber"
                    placeholder="请输入物料编码"
                    clearable
                    @keyup.enter.native="handleQuery_specialmaterial"
                  />
                </el-form-item>
                <el-form-item label="物料名称" prop="materialname">
                  <el-input
                    v-model="specialmaterial.queryParams.materialname"
                    placeholder="请输入名称"
                    clearable
                    @keyup.enter.native="handleQuery_specialmaterial"
                  />
                </el-form-item>
                <el-form-item label="助记码" prop="barcode">
                  <el-input
                    v-model="specialmaterial.queryParams.barcode"
                    placeholder="请输入助记码"
                    clearable
                    @keyup.enter.native="handleQuery_specialmaterial"
                  />
                </el-form-item>
                <el-form-item label="一级分类名称" prop="group1name">
                  <el-select v-model="specialmaterial.queryParams.group1name" @change="specialmaterial_GroupChange('1')" placeholder="请选择分类名称" clearable>
                    <el-option
                      v-for="bank in specialmaterial.materialgroupListShow"
                      :key="bank.group1name"
                      :label="bank.group1name"
                      :value="bank.group1name"
                      @keyup.enter.native="handleQuery_specialmaterial"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="二级分类名称" prop="group2name">
                  <el-select v-model="specialmaterial.queryParams.group2name" @change="specialmaterial_GroupChange('2')" placeholder="请选择分类名称" clearable>
                    <el-option
                      v-for="bank in specialmaterial.materialgroup2ListShow"
                      :key="bank.group1name"
                      :label="bank.group1name"
                      :value="bank.group1name"
                      @keyup.enter.native="handleQuery_specialmaterial"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="三级分类名称" prop="group3name">
                  <el-select v-model="specialmaterial.queryParams.group3name" @change="specialmaterial_GroupChange('3')" placeholder="请选择分类名称" clearable>
                    <el-option
                      v-for="bank in specialmaterial.materialgroup3ListShow"
                      :key="bank.group1name"
                      :label="bank.group1name"
                      :value="bank.group1name"
                      @keyup.enter.native="handleQuery_specialmaterial"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="是否特殊物料" prop="isspecialmaterial">
                  <el-select v-model="specialmaterial.queryParams.isspecialmaterial" placeholder="请选择是否特殊物料" clearable>
                    <el-option
                      v-for="dict in dict.type.yes_no"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>
                </el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery_specialmaterial">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery_specialmaterial">重置</el-button>
              </el-form-item>
            </el-form>

            <el-table v-loading="specialmaterial.loading"
                      :data="specialmaterial.rowList"
                      ref="specialmaterialTable"
                      :row-class-name="rowBillHeadIndex"
                      @row-click="rowClick_specialmaterial"
                      @row-dblclick="rowDoubleClick_specialmaterial"
                      @selection-change="handleSelectionChange_specialmaterial"
                      border
                      stripe
            >
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="物料编码" align="center" prop="materialnumber" width="150"/>
              <el-table-column label="物料名称" align="center" prop="materialname" />
<!--              <el-table-column label="计量单位编码" align="center" prop="baseunitnumber" />-->
              <el-table-column label="计量单位名称" align="center" prop="baseunitname" width="120"/>
<!--              <el-table-column label="物料分类一级编码" align="center" prop="group1number" />-->
              <el-table-column label="助记码" align="center" prop="barcode" width="100"/>
              <el-table-column label="物料分类一级名称" align="center" prop="group1name" width="180" />
<!--              <el-table-column label="物料分类二级编码" align="center" prop="group2number" />-->
              <el-table-column label="物料分类二级名称" align="center" prop="group2name" />
<!--              <el-table-column label="物料分类三级编码" align="center" prop="group3number" />-->
<!--              <el-table-column label="物料分类三级名称" align="center" prop="group3name" />-->
<!--              <el-table-column label="物料分类四级编码" align="center" prop="group4number" />-->
<!--              <el-table-column label="物料分类四级名称" align="center" prop="group4name" />-->
<!--              <el-table-column label="折只数" align="center" prop="qtytoegg" />-->
<!--              <el-table-column label="折蛋数" align="center" prop="qtytodumpling" />-->
<!--              <el-table-column label="折饼数" align="center" prop="qtytocake" />-->
<!--              <el-table-column label="箱规" align="center" prop="boxspecification" />-->
<!--              <el-table-column label="是否特殊物料" align="center" prop="isspecialmaterial">-->
<!--                <template slot-scope="scope">-->
<!--                  <dict-tag :options="dict.type.yes_no" :value="scope.row.isspecialmaterial"/>-->
<!--                </template>-->
<!--              </el-table-column>-->
<!--              <el-table-column label="描述" align="center" prop="description" />-->
<!--              <el-table-column label="简称" align="center" prop="simplename" />-->
              <el-table-column label="规格" align="center" prop="specifications" />
<!--              <el-table-column label="税率" align="center" prop="taxrate" />-->
            </el-table>

            <pagination
              v-show="specialmaterial.total>0"
              :total="specialmaterial.total"
              :page.sync="specialmaterial.queryParams.pageNum"
              :limit.sync="specialmaterial.queryParams.pageSize"
              @pagination="getList_specialmaterial"
            />

          </el-main>
        </el-container>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="toParentPage_specialmaterial">确 定</el-button>
            <el-button @click="specialmaterial.show = false">取 消</el-button>
        </span>
      </el-dialog>
    </template>
    <!--    计量单位-->
    <template>
      <el-dialog
        v-drag
        :close-on-click-modal="true"
        append-to-body width="60%"
        height="600px" title="计量单位"
        :visible.sync="baseunit.show">
        <el-container>
          <el-main>
            <el-form :model="baseunit.queryParams" ref="queryBaseunitForm" size="small" :inline="true"
                     label-width="auto">
              <el-form-item>
                <el-form-item label="编码" prop="number">
                  <el-input
                    v-model="baseunit.queryParams.baseunitnumber"
                    placeholder="请输入编码"
                    clearable
                    @keyup.enter.native="handleQuery_baseunit"
                  />
                </el-form-item>
                <el-form-item label="名称" prop="name">
                  <el-input
                    v-model="baseunit.queryParams.baseunitname"
                    placeholder="请输入名称"
                    clearable
                    @keyup.enter.native="handleQuery_baseunit"
                  />
                </el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery_baseunit">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery_baseunit">重置</el-button>
              </el-form-item>
            </el-form>

            <el-table v-loading="baseunit.loading"
                      :data="baseunit.rowList"
                      ref="baseunitTable"
                      :row-class-name="rowBillHeadIndex"
                      @row-click="rowClick_baseunit"
                      @row-dblclick="rowDoubleClick_baseunit"
                      @selection-change="handleSelectionChange_baseunit"
                      border
                      stripe
            >
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="编码" align="center" prop="baseunitnumber" />
              <el-table-column label="名称" align="center" prop="baseunitname" />
            </el-table>

            <pagination
              v-show="baseunit.total>0"
              :total="baseunit.total"
              :page.sync="baseunit.queryParams.pageNum"
              :limit.sync="baseunit.queryParams.pageSize"
              @pagination="getList_baseunit"
            />

          </el-main>
        </el-container>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="toParentPage_baseunit">确 定</el-button>
            <el-button @click="baseunit.show = false">取 消</el-button>
        </span>
      </el-dialog>
    </template>
    <!--    成本测算列表-->
    <template>
      <el-dialog
        v-drag
        :close-on-click-modal="true"
        append-to-body width="90%"
        height="1500px" title="成本测算"
        :visible.sync="costcalclist.show">
        <el-container>
          <el-main>
            <el-form :model="costcalclist.queryParams" ref="queryCostcalclistForm" size="small" :inline="true"
                     label-width="auto">
              <el-form-item>
                <el-form-item label="单据编号" prop="number">
                  <el-input
                    v-model="costcalclist.queryParams.number"
                    placeholder="请输入单据编号"
                    clearable
                    @keyup.enter.native="handleQuery_costcalclist"
                  />
                </el-form-item>
                <el-form-item label="客户" prop="cfcustomerid">
                  <el-input
                    v-model="costcalclist.queryParams.cfcustomerid"
                    placeholder="请输入客户"
                    clearable
                    @keyup.enter.native="handleQuery_costcalclist"
                  />
                </el-form-item>
                <el-form-item label="产品代码" prop="cfmaterialid">
                  <el-input
                    v-model="costcalclist.queryParams.cfmaterialid"
                    placeholder="请输入产品代码"
                    clearable
                    @keyup.enter.native="handleQuery_costcalclist"
                  />
                </el-form-item>
                <el-form-item label="产品名称" prop="cfmaterialname">
                  <el-input
                    v-model="costcalclist.queryParams.cfmaterialname"
                    placeholder="请输入产品名称"
                    clearable
                    @keyup.enter.native="handleQuery_costcalclist"
                  />
                </el-form-item>
                <el-form-item label="业务日期" prop="fbizdate">
                  <el-date-picker clearable
                                  v-model="costcalclist.queryParams.fbizdate"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  placeholder="请选择业务日期">
                  </el-date-picker>
                </el-form-item>
<!--                <el-form-item label="是否进入产品库" prop="ffivouchered">-->
<!--                  <el-select v-model="costcalclist.queryParams.ffivouchered" placeholder="请选择是否进入产品库" clearable>-->
<!--                    <el-option-->
<!--                      v-for="dict in dict.type.yes_no"-->
<!--                      :key="dict.value"-->
<!--                      :label="dict.label"-->
<!--                      :value="dict.value"-->
<!--                    />-->
<!--                  </el-select>-->
<!--                </el-form-item>-->
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery_costcalclist">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery_costcalclist">重置</el-button>
              </el-form-item>
            </el-form>

            <el-table v-loading="costcalclist.loading"
                      :data="costcalclist.rowList"
                      ref="costcalclistTable"
                      :row-class-name="rowBillHeadIndex"
                      @row-click="rowClick_costcalclist"
                      @row-dblclick="rowDoubleClick_costcalclist"
                      @selection-change="handleSelectionChange_costcalclist"
                      border
                      stripe
            >
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="产品代码" align="center" prop="cfmaterialid" />
              <el-table-column label="产品名称" align="center" prop="cfmaterialname" />
              <el-table-column label="税率" align="center" prop="cftaxrate" />
              <el-table-column label="单据编号" align="center" prop="number" width="180"/>
              <el-table-column label="客户" align="center" prop="cfcustomerid" />
              <el-table-column label="业务日期" align="center" prop="fbizdate" width="180">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.fbizdate, '{y}-{m}-{d}') }}</span>
                </template>
              </el-table-column>
<!--              <el-table-column label="状态" align="center" prop="cfstate"  >-->
<!--                <template slot-scope="scope">-->
<!--                  <dict-tag :options="dict.type.bill_state" :value="scope.row.cfstate"/>-->
<!--                </template>-->
<!--              </el-table-column>-->
<!--              <el-table-column label="是否进入产品库" align="center" prop="ffivouchered"  >-->
<!--                <template slot-scope="scope">-->
<!--                  <dict-tag :options="dict.type.yes_no" :value="scope.row.ffivouchered"/>-->
<!--                </template>-->
<!--              </el-table-column>-->
<!--              <el-table-column label="合计材料成本" align="center" prop="cftotalmaterialcost"  />-->
<!--              <el-table-column label="合计成本" align="center" prop="cftotalcost"  />-->
<!--              <el-table-column label="含税成本" align="center" prop="cftaxcost"  />-->
<!--              <el-table-column label="包装成本" align="center" prop="cfpackcost" />-->
<!--              <el-table-column label="变动费用" align="center" prop="cfalterationfee"  />-->
<!--              <el-table-column label="固定费用" align="center" prop="cffixedfee"  />-->
              <el-table-column label="规格" align="center" prop="cfmodel" />
            </el-table>

            <pagination
              v-show="costcalclist.total>0"
              :total="costcalclist.total"
              :page.sync="costcalclist.queryParams.pageNum"
              :limit.sync="costcalclist.queryParams.pageSize"
              @pagination="getList_costcalclist"
            />

          </el-main>
        </el-container>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="toParentPage_costcalclist">确 定</el-button>
            <el-button @click="costcalclist.show = false">取 消</el-button>
        </span>
      </el-dialog>
    </template>
    <!--    客户-->
    <template>
      <el-dialog
        v-drag
        :close-on-click-modal="true"
        append-to-body width="60%"
        height="600px" title="客户"
        :visible.sync="customer.show">
        <el-container>
          <el-main>
            <el-form :model="customer.queryParams" ref="queryCustomerForm" size="small" :inline="true"
                     label-width="auto">
              <el-form-item>
                <el-form-item label="客户编码" prop="customernumber">
                  <el-input
                    v-model="customer.queryParams.customernumber"
                    placeholder="请输入客户编码"
                    clearable
                    @keyup.enter.native="handleQuery_customer"
                  />
                </el-form-item>
                <el-form-item label="客户名称" prop="customername">
                  <el-input
                    v-model="customer.queryParams.customername"
                    placeholder="请输入客户名称"
                    clearable
                    @keyup.enter.native="handleQuery_customer"
                  />
                </el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery_customer">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery_customer">重置</el-button>
              </el-form-item>
            </el-form>

            <el-table v-loading="customer.loading"
                      :data="customer.rowList"
                      ref="customerTable"
                      :row-class-name="rowBillHeadIndex"
                      @row-click="rowClick_customer"
                      @row-dblclick="rowDoubleClick_customer"
                      @selection-change="handleSelectionChange_customer"
                      border
                      stripe
            >
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="客户编码" align="center" prop="customernumber" />
              <el-table-column label="客户名称" align="center" prop="customername" />
              <el-table-column label="基本分类编码" align="center" prop="groupnumber" />
              <el-table-column label="基本分类名称" align="center" prop="groupname" />
              <el-table-column label="是否内部客户" align="center" prop="isinternal">
                <template slot-scope="scope">
                  <dict-tag :options="dict.type.yes_no" :value="scope.row.isinternal"/>
                </template>
              </el-table-column>
              <el-table-column label="内部公司编码" align="center" prop="internalcompanynumber" />
              <el-table-column label="内部公司名称" align="center" prop="internalcompanyname" />
              <el-table-column label="是否成本中心" align="center" prop="iscostcenter">
                <template slot-scope="scope">
                  <dict-tag :options="dict.type.yes_no" :value="scope.row.iscostcenter"/>
                </template>
              </el-table-column>
              <el-table-column label="成本中心编码" align="center" prop="costcenternumber" />
              <el-table-column label="成本中心名称" align="center" prop="costcentername" />
            </el-table>

            <pagination
              v-show="customer.total>0"
              :total="customer.total"
              :page.sync="customer.queryParams.pageNum"
              :limit.sync="customer.queryParams.pageSize"
              @pagination="getList_customer"
            />

          </el-main>
        </el-container>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="toParentPage_customer">确 定</el-button>
            <el-button @click="customer.show = false">取 消</el-button>
        </span>
      </el-dialog>
    </template>
    <!--    物料分类-->
    <template>
      <el-dialog
        v-drag
        :close-on-click-modal="true"
        append-to-body width="60%"
        height="600px" title="物料分类"
        :visible.sync="materialGroup.show">
        <el-container>
          <el-main>
            <el-form :model="materialGroup.queryParams" ref="querymaterialGroupForm" size="small" :inline="true" label-width="auto">
              <el-form-item>
                <el-form-item label="编码" prop="number">
                  <el-input
                    v-model="materialGroup.queryParams.number"
                    placeholder="请输入编码"
                    clearable
                    @keyup.enter.native="handleQuery_materialGroup"
                  />
                </el-form-item>
                <el-form-item label="名称" prop="name">
                  <el-input
                    v-model="materialGroup.queryParams.name"
                    placeholder="请输入名称"
                    clearable
                    @keyup.enter.native="handleQuery_materialGroup"
                  />
                </el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery_materialGroup">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery_materialGroup">重置</el-button>
              </el-form-item>
            </el-form>
<!--            <el-row :gutter="10" class="mb8">-->
<!--              <el-col :span="1.5">-->
<!--                <el-button-->
<!--                  type="info"-->
<!--                  plain-->
<!--                  icon="el-icon-sort"-->
<!--                  size="mini"-->
<!--                  @click="toggleExpandAll_materialGroup"-->
<!--                >展开/折叠</el-button>-->
<!--              </el-col>-->
<!--            </el-row>-->
            <el-table v-loading="materialGroup.loading"
                      :data="materialGroup.rowList"
                      ref="materialGroupTable"
                      :row-class-name="rowBillHeadIndex"
                      @row-click="rowClick_materialGroup"
                      @row-dblclick="rowDoubleClick_materialGroup"
                      @selection-change="handleSelectionChange_materialGroup"
                      border
                      stripe
                      v-if="materialGroup.refreshTable"
                      :default-expand-all="materialGroup.isExpandAll"
                      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
            >
<!--              row-key="number"-->
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="编码" prop="number" />
              <el-table-column label="名称" align="center" prop="name" />
              <el-table-column label="上级编码" align="center" prop="parentnumber" />
              <el-table-column label="上级名称" align="center" prop="parentname" />
            </el-table>

<!--            <pagination-->
<!--              v-show="materialGroup.total>0"-->
<!--              :total="materialGroup.total"-->
<!--              :page.sync="materialGroup.queryParams.pageNum"-->
<!--              :limit.sync="materialGroup.queryParams.pageSize"-->
<!--              @pagination="getList_materialGroup"-->
<!--            />-->

          </el-main>
        </el-container>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="toParentPage_materialGroup">确 定</el-button>
            <el-button @click="materialGroup.show = false">取 消</el-button>
        </span>
      </el-dialog>
    </template>
    <!--    成本中心-->
    <template>
      <el-dialog
        v-drag
        :close-on-click-modal="true"
        append-to-body width="60%"
        height="600px" title="成本中心"
        :visible.sync="costcenter.show">
        <el-container>
          <el-main>
            <el-form :model="costcenter.queryParams" ref="querycostcenterForm" size="small" :inline="true" label-width="auto">
              <el-form-item>
                <el-form-item label="编码" prop="number">
                  <el-input
                    v-model="costcenter.queryParams.number"
                    placeholder="请输入编码"
                    clearable
                    @keyup.enter.native="handleQuery_costcenter"
                  />
                </el-form-item>
                <el-form-item label="名称" prop="name">
                  <el-input
                    v-model="costcenter.queryParams.name"
                    placeholder="请输入名称"
                    clearable
                    @keyup.enter.native="handleQuery_costcenter"
                  />
                </el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery_costcenter">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery_costcenter">重置</el-button>
              </el-form-item>
            </el-form>
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button
                  type="info"
                  plain
                  icon="el-icon-sort"
                  size="mini"
                  @click="toggleExpandAll_costcenter"
                >展开/折叠</el-button>
              </el-col>
            </el-row>
            <el-table v-loading="costcenter.loading"
                      :data="costcenter.rowList"
                      ref="costcenterTable"
                      :row-class-name="rowBillHeadIndex"
                      @row-click="rowClick_costcenter"
                      @row-dblclick="rowDoubleClick_costcenter"
                      @selection-change="handleSelectionChange_costcenter"
                      border
                      stripe
                      v-if="costcenter.refreshTable"
                      row-key="number"
                      :default-expand-all="costcenter.isExpandAll"
                      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
            >
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="编码" prop="number" />
              <el-table-column label="名称" align="center" prop="name" />
              <el-table-column label="上级编码" align="center" prop="parentnumber" />
              <el-table-column label="上级名称" align="center" prop="parentname" />
            </el-table>

          </el-main>
        </el-container>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="toParentPage_costcenter">确 定</el-button>
            <el-button @click="costcenter.show = false">取 消</el-button>
        </span>
      </el-dialog>
    </template>
  </div>
</template>


<script>

  import {listWfzbase} from "@/api/bomcostestimation/basedocument/wfzbase";
  import {listCategory} from "@/api/bomcostestimation/basedocument/category";
  import {listBomsm} from "@/api/bomcostestimation/basedocument/bomsm";
  import {getMaterialhalf, listMaterialhalf} from "@/api/bomcostestimation/basedocument/materialhalf";
  import {listBaseunit } from "@/api/bomcostestimation/basedocument/baseunit";
  import {listCostcalc, getCostcalc} from "@/api/bomcostestimation/basebill/costcalc";
  import {listCustomer} from "@/api/bomcostestimation/basedocument/customer";
  import {getCalcdemand} from "@/api/bomcostestimation/basebill/calcdemand";
  import {listMaterialgroup} from "@/api/bomcostestimation/basedocument/materialgroup";
  import { listCostcenter} from "@/api/bomcostestimation/basedocument/costcenter";
  import Treeselect from "@riophae/vue-treeselect";
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";

  export default {
    name: "baseDataView",
    dicts: ['bill_state','bom_wfzbase','bom_seasontype','bom_plant','yes_no','bom_customized_product_type','bom_materialsourse','bom_csxq_type','bom_usercategory'],
    props: {
      tobasedata: {
        type: Object
      },
      //成本测算分录表格数据
      bomCostcalc: {},
    },
    data() {
      return {
        //F7数据
        //F7数据对话框数据
        basedatadialog : {
          //定义一个参数用来存储当前需要修改的行数（存在分录的情况下）
          tempTableRowIndex: null,
          //定义一个参数用来判断当前是获取什么类型的数据
          f7dataType: null,
          //判断是哪一个Form表单需要设置信息
          index: null,
          wfzbase : {
            show : false
          },
          category : {
            show : false
          },
          baseunit : {
            show : false
          },
          costcalclist : {
            show : false
          },
          customer : {
            show : false
          },
          specialmaterial : {
            show : false,
            isspecialmaterial: null,
          },
          materialhalf : {
            show : false
          },
          costcalc:{
            //是否展示对话框
            show:false,
            isExpandAll:false,
            refreshTable:true,
            entryloading: false,
            indexColumnWidth:50,
            entryParameter: {
              entryName: '原材料分录',
              entry1Show: true,
              entry2Show: false
            },
            data:{},
            // 成本测算分录表格数据
            bomCostcalcentryList: [],
            bomCostcalcentryList2: [],
          },
        },
        //基地
        wfzbase: {
          // 遮罩层
          loading: true,
          //是否展示对话框
          show: false,
          //总数
          total: 0,
          // 物料表格数据
          rowList: [],
          //选中的数据
          selectedrowList: [],
          //查询参数
          queryParams: {
            pageNum: 1,
            pageSize: 10,
            isEnable: 1,
            number: null,
            name: null
          }
        },
        //类别
        category: {
          // 遮罩层
          loading: true,
          //是否展示对话框
          show: false,
          //总数
          total: 0,
          // 物料表格数据
          rowList: [],
          //选中的数据
          selectedrowList: [],
          //查询参数
          queryParams: {
            pageNum: 1,
            pageSize: 10,
            isEnable: 1,
            number: null,
            name: null
          }
        },
        //物料分类
        materialGroup: {
          // 遮罩层
          loading: true,
          //是否展示对话框
          show: false,
          //总数
          total: 0,
          // 是否展开，默认全部展开
          isExpandAll: false,
          // 重新渲染表格状态
          refreshTable: true,
          // 物料表格数据
          rowList: [],
          //选中的数据
          selectedrowList: [],
          //查询参数
          queryParams: {
            isEnable: 1,
            number: null,
            name: null
          }
        },
        //成本中心
        costcenter: {
          // 遮罩层
          loading: true,
          //是否展示对话框
          show: false,
          //总数
          total: 0,
          // 是否展开，默认全部展开
          isExpandAll: false,
          // 重新渲染表格状态
          refreshTable: true,
          // 物料表格数据
          rowList: [],
          //选中的数据
          selectedrowList: [],
          //查询参数
          queryParams: {
            isEnable: 1,
            number: null,
            name: null
          }
        },
        //计量单位
        baseunit: {
          // 遮罩层
          loading: true,
          //是否展示对话框
          show: false,
          //总数
          total: 0,
          // 物料表格数据
          rowList: [],
          //选中的数据
          selectedrowList: [],
          //查询参数
          queryParams: {
            pageNum: 1,
            pageSize: 10,
            isEnable: 1,
            baseunitnumber: null,
            baseunitname: null
          }
        },
        //客户
        customer: {
          // 遮罩层
          loading: true,
          //是否展示对话框
          show: false,
          //总数
          total: 0,
          // 物料表格数据
          rowList: [],
          //选中的数据
          selectedrowList: [],
          //查询参数
          queryParams: {
            pageNum: 1,
            pageSize: 10,
            isEnable: 1,
            customernumber: null,
            customername: null
          }
        },
        //成本测算
        costcalclist: {
          // 遮罩层
          loading: true,
          //是否展示对话框
          show: false,
          //总数
          total: 0,
          // 物料表格数据
          rowList: [],
          //选中的数据
          selectedrowList: [],
          //查询参数
          queryParams: {
            pageNum: 1,
            pageSize: 10,
            fcreatorid: null,
            fcreatetime: null,
            flastupdateuserid: null,
            flastupdatetime: null,
            number: null,
            fbizdate: null,
            fhandlerid: null,
            fdescription: null,
            fhaseffected: null,
            fauditorid: null,
            fsourcebillid: null,
            fsourcefunction: null,
            ffivouchered: null,
            cfcustomerid: null,
            cftotalmaterialcost: null,
            cftotalcost: null,
            cftaxcost: null,
            cfpackcost: null,
            cfalterationfee: null,
            cffixedfee: null,
            cftaxrate: null,
            cfstate: "AUDIT",
            cfmaterialid: null,
            cfmaterialname: null,
            cfmodel: null,
            cfbaseunit: null,
            cfprojecttxt: null,
            cfremarktxt: null,
            cfseasontypeid: null,
            cfwfzbaseid: null
          },
        },
        //特殊物料
        specialmaterial: {
          // 遮罩层
          loading: true,
          //是否展示对话框
          show: false,
          //总数
          total: 0,
          // 物料表格数据
          rowList: [],
          //选中的数据
          selectedrowList: [],
          //物料分类原始数组
          materialgroupList:[],
          materialgroup2List:[],
          materialgroup3List:[],
          //物料分类展示数组
          materialgroupListShow:[],
          materialgroup2ListShow:[],
          materialgroup3ListShow:[],
          //查询参数
          queryParams: {
            pageNum: 1,
            pageSize: 10,
            isEnable: 1,
            materialname: null,
            materialnumber: null,
            baseunitname: null,
            barcode: null,
            group1name: null,
            group1number: null,
            group2name: null,
            group3name: null,
            group2number: null,
            group3number: null,
            isspecialmaterial: null,
          }
        },
        //测算需求
        calcdemand: {
          fid:null,
          types:[],
          //是否展示对话框
          show:false,
          // 成本测算分录表格数据
          bomCalcdemandentryList:[],
          bomCalcdemandentryListSumAmount:[],
          data:{},
        },
        //物料BOM
        materialhalf: {
          // 遮罩层
          loading: true,
          //是否展示对话框
          show: false,
          //总数
          total: 0,
          // 物料表格数据
          rowList: [],
          //选中的数据
          selectedrowList: [],
          //查询参数
          queryParams: {
            pageNum: 1,
            pageSize: 10,
            isEnable: 1,
            cfmaterialnumber: null,
            cfverson: null,
            cfmaterialname: null
          }
        },
        //公用参数
        //传递到父组件的数据
        transData: {
          //基地数据
          wfzbase: null,
          //类别数据
          category: null,
          //计量单位数据
          baseunit: null,
          //成本测算数据
          costcalclist: null,
          //客户数据
          customer: null,
          //类别数据
          specialmaterial: null,
          //物料BOM数据
          materialhalf: null,
        },
      }
    },
    watch: {
      "tobasedata.wfzbase.show": {
        handler() {
          this.resetForm("queryWfzbaseForm");
          this.getList_wfzbase()
          this.wfzbase.show = !this.wfzbase.show;
        },
        deep: true
      },
      "tobasedata.category.show": {
        handler() {
          this.resetForm("queryCategoryForm");
          this.getList_category()
          this.category.show = !this.category.show;
        },
        deep: true
      },
      "tobasedata.baseunit.show": {
        handler() {
          this.resetForm("queryBaseunitForm");
          this.getList_baseunit()
          this.baseunit.show = !this.baseunit.show;
        },
        deep: true
      },
      "tobasedata.costcalclist.show": {
        handler() {
          this.resetForm("queryCostcalclistForm");
          this.costcalclist.queryParams.ffivouchered = this.tobasedata.costcalclist.queryParams.ffivouchered;
          this.costcalclist.queryParams.cfmaterialid = null;
          if(this.tobasedata.costcalclist.cfmaterialhalfnumb!=null&&this.tobasedata.costcalclist.cfmaterialhalfnumb!=0){
            this.costcalclist.queryParams.cfmaterialid = this.tobasedata.costcalclist.cfmaterialhalfnumb;
          }
          this.getList_costcalclist()
          this.costcalclist.show = !this.costcalclist.show;
        },
        deep: true
      },
      "tobasedata.customer.show": {
        handler() {
          this.resetForm("queryCustomerForm");
          this.getList_customer()
          this.customer.show = !this.customer.show;
        },
        deep: true
      },
      "tobasedata.specialmaterial.show": {
        handler() {
          listMaterialgroup(null).then(response => {
            let data = response.data;
            let materialgroupList = [];
            let materialgroup2List = [];
            let materialgroup3List = [];
            for (let i = 0; i < data.length; i++) {
              let number = data[i].number;
              if(number.length==2){
                let materialGroup ={
                  group1number : data[i].number,
                  group1name : data[i].name,
                }
                materialgroupList.push(materialGroup)
              }else if(number.length==4){
                let materialGroup ={
                  group1number : data[i].number,
                  group1name : data[i].name
                }
                materialgroup2List.push(materialGroup)
              }else if(number.length==6){
                let materialGroup ={
                  group1number : data[i].number,
                  group1name : data[i].name
                }
                materialgroup3List.push(materialGroup)
              }
            }
            this.specialmaterial.materialgroupList = materialgroupList;
            this.specialmaterial.materialgroup2List = materialgroup2List;
            this.specialmaterial.materialgroup3List = materialgroup3List;
            this.specialmaterial.materialgroupListShow = materialgroupList;
            this.specialmaterial.materialgroup2ListShow = materialgroup2List;
            this.specialmaterial.materialgroup3ListShow = materialgroup3List;
            this.resetForm("querySpecialMaterialForm");
            this.specialmaterial.show = !this.specialmaterial.show;
            this.specialmaterial.queryParams.isspecialmaterial = null;
            if(this.tobasedata.specialmaterial.isspecialmaterial!=null&&this.tobasedata.specialmaterial.isspecialmaterial.length!=0){
              let isspecialmaterial = this.tobasedata.specialmaterial.isspecialmaterial;
              this.specialmaterial.queryParams.isspecialmaterial = isspecialmaterial;
            }
            this.specialmaterial.queryParams.materialnumber = null;
            if(this.tobasedata.specialmaterial.number!=null&&this.tobasedata.specialmaterial.number.length!=0){
              let isspecialmaterial = this.tobasedata.specialmaterial.number;
              this.specialmaterial.queryParams.materialnumber = isspecialmaterial;
            }
            this.getList_specialmaterial()
          });
        },
        deep: true
      },
      "tobasedata.materialhalf.show": {
        handler() {
          this.resetForm("queryMaterialhalfForm");
          this.materialhalf.queryParams.cfmaterialnumber = null;
          if(this.tobasedata.materialhalf.cfmaterialnumber!=null&&this.tobasedata.materialhalf.cfmaterialnumber!=0){
            this.materialhalf.queryParams.cfmaterialnumber = this.tobasedata.materialhalf.cfmaterialnumber;
          }
          this.getList_materialhalf()
          this.materialhalf.show = !this.materialhalf.show;
        },
        deep: true
      },
      "bomCostcalc.costcalc.show": {
        handler() {
          this.getCostcalcDetail()
          this.basedatadialog.costcalc.show = true;
        },
        deep: true
      },
      "tobasedata.calcdemand.show": {
        handler() {
          let fid = this.tobasedata.calcdemand.fid;
          getCalcdemand(fid).then(response => {
            this.calcdemand.data = response.data;
            if (response.data.fcustomizedproducttype != null) {
              var tempList = response.data.fcustomizedproducttype.split(',')
              this.calcdemand.types = [];
              for (var item in tempList) {
                this.calcdemand.types.push(tempList[item])
              }
            }
            this.calcdemand.bomCalcdemandentryList = response.data.bomCalcdemandentryList;
            let bomCalcdemandentryList = this.calcdemand.bomCalcdemandentryList;
            let obj = {};
            obj.cftotalmaterialcost = 0;
            obj.cftotalcost = 0;
            obj.cftaxcost = 0;
            obj.cfpackcost = 0;
            obj.cfalterationfee = 0;
            obj.cffixedfee = 0;
            for (let i = 0; i < bomCalcdemandentryList.length; i++) {
              let listElement = bomCalcdemandentryList[i];
              if(listElement.cfcategory=="0"&&listElement.cfboxamount=="1"){
                obj.cftotalmaterialcost += (listElement.cftotalmaterialcost-0);
                obj.cftotalcost += (listElement.cftotalcost-0);
                obj.cftaxcost += (listElement.cftaxcost-0);
                obj.cfpackcost += (listElement.cfpackcost-0);
                obj.cfalterationfee += (listElement.cfalterationfee-0);
                obj.cffixedfee += (listElement.cffixedfee-0);
              }
              listElement.cftotalcount = (listElement.cffoldnumber-0)*(listElement.cfquotecount-0);
            }
            this.calcdemand.bomCalcdemandentryListSumAmount = [];
            this.calcdemand.bomCalcdemandentryListSumAmount.push(obj)
            this.calcdemand.show = !this.calcdemand.show;
          });
        },
        deep: true
      },
      "tobasedata.materialGroup.show": {
        handler() {
          this.resetForm("querymaterialGroupForm");
          this.getList_materialGroup()
          this.materialGroup.show = !this.materialGroup.show;
        },
        deep: true
      },
      "tobasedata.costcenter.show": {
        handler() {
          this.resetForm("querycostcenterForm");
          this.getList_costcenter()
          this.costcenter.show = !this.costcenter.show;
        },
        deep: true
      },
    },
    methods: {
      //公用方法--
      /** 单据头序号 */
      rowBillHeadIndex({row, rowIndex}) {
        row.index = rowIndex + 1;
      },
      //基地相关方法
      /** 查询基地列表 */
      getList_wfzbase() {
        this.wfzbase.loading = true;
        listWfzbase(this.wfzbase.queryParams).then(response => {
          this.wfzbase.rowList = response.rows;
          this.wfzbase.total = response.total;
          this.wfzbase.loading = false;
        });
      },
      /** 基地搜索按钮操作 */
      handleQuery_wfzbase() {
        this.wfzbase.queryParams.pageNum = 1;
        this.getList_wfzbase();
      },
      /** 基地重置按钮操作 */
      resetQuery_wfzbase() {
        this.resetForm("queryWfzbaseForm");
        this.handleQuery_wfzbase();
      },
      /** 基地监听row-click事件，实现选中 */
      rowClick_wfzbase(row, column, event) {
        let refsElTable = this.$refs.wfzbaseTable; // 获取表格对象
        refsElTable.toggleRowSelection(row);  //如过重复选中，则取消选中
      },
      /** 基地监听双击事件，实现推送当前行*/
      rowDoubleClick_wfzbase(row, column, event) {
        let refsElTable = this.$refs.wfzbaseTable; // 获取表格对象
        refsElTable.clearSelection(); //清空表格选中数据
        refsElTable.toggleRowSelection(row);  //选中当前行，如过重复选中，则取消选中
        this.toParentPage_wfzbase(); //调用推送方法
      },
      /**  基地多选框选中数据*/
      handleSelectionChange_wfzbase(selection) {
        this.wfzbase.selectedrowList = selection;
        this.transData.wfzbase = this.wfzbase.selectedrowList[0]
      },
      /** 基地向父页面传输数据 */
      toParentPage_wfzbase() {
        if (this.wfzbase.selectedrowList.length > 1) {
          this.$modal.msgError("只能选中一条数据！")
          return;
        }
        this.wfzbase.show = false;
        let tempdata = this.transData
        this.$emit('emitToParent', tempdata);
      },
      //物料BOM相关方法
      /** 物料BOM基地列表 */
      getList_materialhalf() {
        this.materialhalf.loading = true;
        listMaterialhalf(this.materialhalf.queryParams).then(response => {
          this.materialhalf.rowList = response.rows;
          this.materialhalf.total = response.total;
          this.materialhalf.loading = false;
        });
      },
      /** 物料BOM搜索按钮操作 */
      handleQuery_materialhalf() {
        this.materialhalf.queryParams.pageNum = 1;
        this.getList_materialhalf();
      },
      /** 物料BOM重置按钮操作 */
      resetQuery_materialhalf() {
        this.resetForm("queryMaterialhalfForm");
        this.handleQuery_materialhalf();
      },
      /** 物料BOM监听row-click事件，实现选中 */
      rowClick_materialhalf(row, column, event) {
        let refsElTable = this.$refs.materialhalfTable; // 获取表格对象
        refsElTable.toggleRowSelection(row);  //如过重复选中，则取消选中
      },
      /** 物料BOM监听双击事件，实现推送当前行*/
      rowDoubleClick_materialhalf(row, column, event) {
        let refsElTable = this.$refs.materialhalfTable; // 获取表格对象
        refsElTable.clearSelection(); //清空表格选中数据
        refsElTable.toggleRowSelection(row);  //选中当前行，如过重复选中，则取消选中
        this.toParentPage_materialhalf(); //调用推送方法
      },
      /**  物料BOM多选框选中数据*/
      handleSelectionChange_materialhalf(selection) {
        this.materialhalf.selectedrowList = selection;
        this.transData.materialhalf = this.materialhalf.selectedrowList[0]
      },
      /** 物料BOM向父页面传输数据 */
      toParentPage_materialhalf() {
        if (this.materialhalf.selectedrowList.length > 1) {
          this.$modal.msgError("只能选中一条数据！")
          return;
        }
        let materialhalf = this.transData.materialhalf;
        if(materialhalf==null||materialhalf==undefined){
          this.materialhalf.show = false;
          let tempdata = this.transData
          this.$emit('emitToParent', tempdata);
        }else{
          getMaterialhalf(materialhalf.fid).then(response => {
            this.transData.materialhalf = response.data;
            this.transData.materialhalf.rowListbomMaterialhalfentryList = response.data.rowListbomMaterialhalfentryList;
          }).then(() => {
            this.materialhalf.show = false;
            let tempdata = this.transData
            this.$emit('emitToParent', tempdata);
          });
        }
      },
      //类别相关方法
      /** 查询类别列表 */
      getList_category() {
        this.category.loading = true;
        listCategory(this.category.queryParams).then(response => {
          this.category.rowList = response.rows;
          this.category.total = response.total;
          this.category.loading = false;
        });
      },
      /** 类别搜索按钮操作 */
      handleQuery_category() {
        this.category.queryParams.pageNum = 1;
        this.getList_category();
      },
      /** 类别重置按钮操作 */
      resetQuery_category() {
        this.resetForm("queryCategoryForm");
        this.handleQuery_category();
      },
      /** 类别监听row-click事件，实现选中 */
      rowClick_category(row, column, event) {
        let refsElTable = this.$refs.categoryTable; // 获取表格对象
        refsElTable.toggleRowSelection(row);  //如过重复选中，则取消选中
      },
      /** 类别监听双击事件，实现推送当前行*/
      rowDoubleClick_category(row, column, event) {
        let refsElTable = this.$refs.categoryTable; // 获取表格对象
        refsElTable.clearSelection(); //清空表格选中数据
        refsElTable.toggleRowSelection(row);  //选中当前行，如过重复选中，则取消选中
        this.toParentPage_category(); //调用推送方法
      },
      /**  类别多选框选中数据*/
      handleSelectionChange_category(selection) {
        this.category.selectedrowList = selection;
        this.transData.category = this.category.selectedrowList[0]
      },
      /** 类别向父页面传输数据 */
      toParentPage_category() {
        if (this.category.selectedrowList.length > 1) {
          this.$modal.msgError("只能选中一条数据！")
          return;
        }
        this.category.show = false;
        let tempdata = this.transData
        this.$emit('emitToParent', tempdata);
      },
      //计量单位相关方法
      /** 查询计量单位列表 */
      getList_baseunit() {
        this.baseunit.loading = true;
        listBaseunit(this.baseunit.queryParams).then(response => {
          this.baseunit.rowList = response.rows;
          this.baseunit.total = response.total;
          this.baseunit.loading = false;
        });
      },
      /** 计量单位搜索按钮操作 */
      handleQuery_baseunit() {
        this.baseunit.queryParams.pageNum = 1;
        this.getList_baseunit();
      },
      /** 计量单位重置按钮操作 */
      resetQuery_baseunit() {
        this.resetForm("queryBaseunitForm");
        this.handleQuery_baseunit();
      },
      /** 计量单位监听row-click事件，实现选中 */
      rowClick_baseunit(row, column, event) {
        let refsElTable = this.$refs.baseunitTable; // 获取表格对象
        refsElTable.toggleRowSelection(row);  //如过重复选中，则取消选中
      },
      /** 计量单位监听双击事件，实现推送当前行*/
      rowDoubleClick_baseunit(row, column, event) {
        let refsElTable = this.$refs.baseunitTable; // 获取表格对象
        refsElTable.clearSelection(); //清空表格选中数据
        refsElTable.toggleRowSelection(row);  //选中当前行，如过重复选中，则取消选中
        this.toParentPage_baseunit(); //调用推送方法
      },
      /**  计量单位多选框选中数据*/
      handleSelectionChange_baseunit(selection) {
        this.baseunit.selectedrowList = selection;
        this.transData.baseunit = this.baseunit.selectedrowList[0]
      },
      /** 计量单位向父页面传输数据 */
      toParentPage_baseunit() {
        if (this.baseunit.selectedrowList.length > 1) {
          this.$modal.msgError("只能选中一条数据！")
          return;
        }
        this.baseunit.show = false;
        let tempdata = this.transData
        this.$emit('emitToParent', tempdata);
      },
      //特殊物料相关方法
      /** 查询特殊物料列表 */
      getList_specialmaterial() {
        this.specialmaterial.loading = true;
        listBomsm(this.specialmaterial.queryParams).then(response => {
          this.specialmaterial.rowList = response.rows;
          this.specialmaterial.total = response.total;
          this.specialmaterial.loading = false;
        });
      },
      /** 特殊物料搜索按钮操作 */
      handleQuery_specialmaterial() {
        this.specialmaterial.queryParams.pageNum = 1;
        this.getList_specialmaterial();
      },
      //物料分类变化触发
      specialmaterial_GroupChange(type){
        switch (type){
          case "1":
            let materialgroupList = this.specialmaterial.materialgroupList;
            let group1name = this.specialmaterial.queryParams.group1name;
            this.specialmaterial.queryParams.group2name = null;
            let group1number = null;
            for (let i = 0; i < materialgroupList.length; i++) {
              let listElement = materialgroupList[i];
              if (listElement.group1name == group1name) {
                group1number = listElement.group1number;
                break;
              }
            }
            let materialgroup2ListShow = structuredClone(this.specialmaterial.materialgroup2List);
            for (let i = materialgroup2ListShow.length-1; group1name!=null&&group1name.length>0&&i >= 0; i--) {
              let listElement1 = materialgroup2ListShow[i];
              if (listElement1.group1number.substring(0,2) != group1number) {
                materialgroup2ListShow.splice(i, 1);
              }
            }
            this.specialmaterial.materialgroup2ListShow = materialgroup2ListShow;
          case "2":
            let materialgroup2List = this.specialmaterial.materialgroup2List;
            let group2name = this.specialmaterial.queryParams.group2name;
            this.specialmaterial.queryParams.group3name = null;
            let group2number = null;
            for (let i1 = 0; i1 < this.specialmaterial.materialgroup2List.length; i1++) {
              let listElement2 = materialgroup2List[i1];
              if (listElement2.group1name == group2name) {
                group2number = listElement2.group1number;
                break;
              }
            }
            let materialgroup3ListShow = structuredClone(this.specialmaterial.materialgroup3List);
            for (let i2 = materialgroup3ListShow.length-1; group2name!=null&&group2name.length>0&&i2 >= 0; i2--) {
              let listElement3 = materialgroup3ListShow[i2];
              if (listElement3.group1number.substring(0,4) != group2number) {
                materialgroup3ListShow.splice(i2, 1);
              }
            }
            this.specialmaterial.materialgroup3ListShow = materialgroup3ListShow;
        }
      },
      /** 特殊物料重置按钮操作 */
      resetQuery_specialmaterial() {
        this.resetForm("querySpecialMaterialForm");
        this.handleQuery_specialmaterial();
      },
      /** 特殊物料监听row-click事件，实现选中 */
      rowClick_specialmaterial(row, column, event) {
        let refsElTable = this.$refs.specialmaterialTable; // 获取表格对象
        refsElTable.toggleRowSelection(row);  //如过重复选中，则取消选中
      },
      /** 特殊物料监听双击事件，实现推送当前行*/
      rowDoubleClick_specialmaterial(row, column, event) {
        let refsElTable = this.$refs.specialmaterialTable; // 获取表格对象
        refsElTable.clearSelection(); //清空表格选中数据
        refsElTable.toggleRowSelection(row);  //选中当前行，如过重复选中，则取消选中
        this.toParentPage_specialmaterial(); //调用推送方法
      },
      /**  特殊物料多选框选中数据*/
      handleSelectionChange_specialmaterial(selection) {
        this.specialmaterial.selectedrowList = selection;
        this.transData.specialmaterial = this.specialmaterial.selectedrowList[0]
      },
      /** 特殊物料向父页面传输数据 */
      toParentPage_specialmaterial() {
        if (this.specialmaterial.selectedrowList.length > 1) {
          this.$modal.msgError("只能选中一条数据！")
          return;
        }
        this.specialmaterial.show = false;
        let tempdata = this.transData
        this.$emit('emitToParent', tempdata);
      },

      rowBomCostcalcentryIndex({ row, rowIndex }) {
        // row.index = rowIndex + 1;
      },
      rowBomCalcdemandIndex({ row, rowIndex }) {
        row.index = rowIndex + 1;
      },
      getCostcalcDetail(){
        this.basedatadialog.costcalc.data = this.bomCostcalc.costcalc.data
        this.basedatadialog.costcalc.bomCostcalcentryList = this.bomCostcalc.costcalc.data.bomCostcalcentryList
        this.basedatadialog.costcalc.bomCostcalcentryList = this.setTreeDataIncludeOrdinalwidth(this.basedatadialog.costcalc.bomCostcalcentryList);
      },
      setTreeDataIncludeOrdinalwidth(source){
        source = this.setTreeData(source);
        source = this.getTreeData(source);
        this.calculateIndexColumnWidth(source);
        source = this.setTreeData(source);
        this.basedatadialog.costcalc.bomCostcalcentryList2 = this.filterList(source);
        return source;
      },
      isHisCbcs(row){
        return false;
      },
      setTreeData(source){
        let filter = this.handleTree(source, "cfbomcostcalcentryid", "cfrawmaterialnumbe");
        filter = this.assignIndexes(filter, '', 1);
        return  filter;
      },
      assignIndexes(data, parentIndex, startIndex) {
        let index = startIndex;
        let list = [];
        data.forEach(item => {
          const newIndex = parentIndex ? `${parentIndex}.${index}` : `${index}`;
          item.index = newIndex;
          list.push(item);
          if (item.children && item.children.length > 0) {
            this.assignIndexes(item.children, newIndex, 1);
          }
          index++;
        });
        return list;
      },
      getTreeData(source){
        let list = [];
        if(source==undefined){
          source = [];
        }
        for (let i = 0; i < source.length; i++) {
          let children = source[i];
          this.recursivelyGetChildren(children, list);
        }
        for (let i = 0; i < list.length; i++) {
          list[i].children = [];
        }
        return list;
      },
      recursivelyGetChildren(children, list) {
        list.push(children);
        if (children.children && children.children.length > 0) {
          for (let i = 0; i < children.children.length; i++) {
            this.recursivelyGetChildren(children.children[i], list);
          }
        }
      },
      /** 展开/折叠操作 */
      toggleExpandAll() {
        this.basedatadialog.costcalc.refreshTable = false;
        this.basedatadialog.costcalc.isExpandAll = !this.basedatadialog.costcalc.isExpandAll;
        this.$nextTick(() => {
          this.basedatadialog.costcalc.refreshTable = true;
        });
      },
      //展示分录5
      showEntryAmount() {
        this.basedatadialog.costcalc.entryParameter.entryName = '费用分录';
        this.basedatadialog.costcalc.entryParameter.entry2Show = true;
        this.basedatadialog.costcalc.entryParameter.entry1Show = false;
      },
      //展示分录6
      showEntryMaterial() {
        this.basedatadialog.costcalc.entryParameter.entryName = '原材料分录';
        this.basedatadialog.costcalc.entryParameter.entry1Show = true;
        this.basedatadialog.costcalc.entryParameter.entry2Show = false;
      },
      calculateIndexColumnWidth(list) {
        let maxLength = 0;
        list.forEach(item => {
          if (item.index!=undefined&&item.index!=null&&item.index.length!=undefined&&item.index.length!=null&&item.index.length > maxLength) {
            maxLength = item.index.length;
          }
        });
        // 假设每个字符占用 10px 的宽度
        this.basedatadialog.costcalc.indexColumnWidth = maxLength * 11 + 50; // 加上一些额外的空间
      },
      /** 过滤空节点 */
      filterList(source) {
        const filterRecursive = (items) => {
          if (!Array.isArray(items)) {
            return []; // 如果 items 不是数组，返回空数组
          }
          return items
            .filter(item => Array.isArray(item.children) && item.children.length > 0)
            .map(item => ({
              ...item,
              children: filterRecursive(item.children) // 递归过滤子节点
            }));
        };
        return filterRecursive(source);
      },
      //成本测算相关方法
      /** 查询成本测算列表 */
      getList_costcalclist() {
        this.costcalclist.loading = true;
        listCostcalc(this.costcalclist.queryParams).then(response => {
          this.costcalclist.rowList = response.rows;
          this.costcalclist.total = response.total;
          this.costcalclist.loading = false;
        });
      },
      /** 成本测算搜索按钮操作 */
      handleQuery_costcalclist() {
        this.costcalclist.queryParams.pageNum = 1;
        this.getList_costcalclist();
      },
      /** 成本测算重置按钮操作 */
      resetQuery_costcalclist() {
        this.resetForm("queryCostcalclistForm");
        this.handleQuery_costcalclist();
      },
      /** 成本测算监听row-click事件，实现选中 */
      rowClick_costcalclist(row, column, event) {
        let refsElTable = this.$refs.costcalclistTable; // 获取表格对象
        refsElTable.toggleRowSelection(row);  //如过重复选中，则取消选中
      },
      /** 成本测算监听双击事件，实现推送当前行*/
      rowDoubleClick_costcalclist(row, column, event) {
        let refsElTable = this.$refs.costcalclistTable; // 获取表格对象
        refsElTable.clearSelection(); //清空表格选中数据
        refsElTable.toggleRowSelection(row);  //选中当前行，如过重复选中，则取消选中
        this.toParentPage_costcalclist(); //调用推送方法
      },
      /**  成本测算多选框选中数据*/
      handleSelectionChange_costcalclist(selection) {
        this.costcalclist.selectedrowList = selection;
        this.transData.costcalclist = this.costcalclist.selectedrowList[0]
      },
      /** 成本测算向父页面传输数据 */
      toParentPage_costcalclist() {
        if (this.costcalclist.selectedrowList.length > 1) {
          this.$modal.msgError("只能选中一条数据！")
          return;
        }
        let costcalclist = this.transData.costcalclist;
        if(costcalclist==null||costcalclist==undefined){
          this.costcalclist.show = false;
          let tempdata = this.transData
          this.$emit('emitToParent', tempdata);
        }
        let fid = costcalclist.fid;
        getCostcalc(fid).then(response => {
          this.transData.costcalclist = response.data;
          this.transData.costcalclist.bomCostcalcentryList = response.data.bomCostcalcentryList;
        }).then(response=>{
          this.costcalclist.show = false;
          let tempdata = this.transData
          this.$emit('emitToParent', tempdata);
        });
      },
      //客户相关方法
      /** 查询客户列表 */
      getList_customer() {
        this.customer.loading = true;
        listCustomer(this.customer.queryParams).then(response => {
          this.customer.rowList = response.rows;
          this.customer.total = response.total;
          this.customer.loading = false;
        });
      },
      /** 客户搜索按钮操作 */
      handleQuery_customer() {
        this.customer.queryParams.pageNum = 1;
        this.getList_customer();
      },
      /** 客户重置按钮操作 */
      resetQuery_customer() {
        this.resetForm("queryCustomerForm");
        this.handleQuery_customer();
      },
      /** 客户监听row-click事件，实现选中 */
      rowClick_customer(row, column, event) {
        let refsElTable = this.$refs.customerTable; // 获取表格对象
        refsElTable.toggleRowSelection(row);  //如过重复选中，则取消选中
      },
      /** 客户监听双击事件，实现推送当前行*/
      rowDoubleClick_customer(row, column, event) {
        let refsElTable = this.$refs.customerTable; // 获取表格对象
        refsElTable.clearSelection(); //清空表格选中数据
        refsElTable.toggleRowSelection(row);  //选中当前行，如过重复选中，则取消选中
        this.toParentPage_customer(); //调用推送方法
      },
      /**  客户多选框选中数据*/
      handleSelectionChange_customer(selection) {
        this.customer.selectedrowList = selection;
        this.transData.customer = this.customer.selectedrowList[0]
      },
      /** 客户向父页面传输数据 */
      toParentPage_customer() {
        if (this.customer.selectedrowList.length > 1) {
          this.$modal.msgError("只能选中一条数据！")
          return;
        }
        this.customer.show = false;
        let tempdata = this.transData
        this.$emit('emitToParent', tempdata);
      },
      //物料分类相关方法
      /** 查询物料分类列表 */
      getList_materialGroup() {
        this.materialGroup.loading = true;
        listMaterialgroup(this.materialGroup.queryParams).then(response => {
          this.materialGroup.rowList = this.handleTree(response.data, "number", "parentnumber");
          this.materialGroup.loading = false;
        });
      },
      /** 物料分类搜索按钮操作 */
      handleQuery_materialGroup() {
        this.getList_materialGroup();
      },
      /** 物料分类重置按钮操作 */
      resetQuery_materialGroup() {
        this.resetForm("querymaterialGroupForm");
        this.handleQuery_materialGroup();
      },
      /** 物料分类监听row-click事件，实现选中 */
      rowClick_materialGroup(row, column, event) {
        let refsElTable = this.$refs.materialGroupTable; // 获取表格对象
        refsElTable.toggleRowSelection(row);  //如过重复选中，则取消选中
      },
      /** 物料分类监听双击事件，实现推送当前行*/
      rowDoubleClick_materialGroup(row, column, event) {
        let refsElTable = this.$refs.materialGroupTable; // 获取表格对象
        refsElTable.clearSelection(); //清空表格选中数据
        refsElTable.toggleRowSelection(row);  //选中当前行，如过重复选中，则取消选中
        this.toParentPage_materialGroup(); //调用推送方法
      },
      /** 展开/折叠操作 */
      toggleExpandAll_materialGroup() {
        this.materialGroup.refreshTable = false;
        this.materialGroup.isExpandAll = !this.materialGroup.isExpandAll;
        this.$nextTick(() => {
          this.materialGroup.refreshTable = true;
        });
      },
      /**  物料分类多选框选中数据*/
      handleSelectionChange_materialGroup(selection) {
        this.materialGroup.selectedrowList = selection;
        this.transData.materialGroup = this.materialGroup.selectedrowList[0]
      },
      /** 物料分类向父页面传输数据 */
      toParentPage_materialGroup() {
        if (this.materialGroup.selectedrowList.length > 1) {
          this.$modal.msgError("只能选中一条数据！")
          return;
        }
        if(this.transData.materialGroup.number.length!=2){
          this.$modal.msgError("只能选择一级编码！")
          return;
        }else if(this.transData.materialGroup.number.length==2){
          this.materialGroup.show = false;
          let tempdata = this.transData
          this.$emit('emitToParent', tempdata);
        }else if(this.transData.materialGroup.number.length==8){
          this.transData.materialGroup.group3number = this.transData.materialGroup.parentnumber;
          this.transData.materialGroup.group3name = this.transData.materialGroup.parentname;
          let queryParams = {
            number: this.transData.materialGroup.parentnumber,
            name: this.transData.materialGroup.parentname
          }
          listMaterialgroup(queryParams).then(response => {
            let data = response.data;
            this.transData.materialGroup.group2number = data[0].parentnumber;
            this.transData.materialGroup.group2name = data[0].parentname;
            queryParams.number = data[0].parentnumber;
            queryParams.name = data[0].parentname;
          }).then(response => {
            listMaterialgroup(queryParams).then(response => {
              let data = response.data;
              this.transData.materialGroup.group1number = data[0].parentnumber;
              this.transData.materialGroup.group1name = data[0].parentname;
              this.materialGroup.show = false;
              let tempdata = this.transData
              this.$emit('emitToParent', tempdata);
            })
          });
        }
      },
      //成本中心相关方法
      /** 查询成本中心列表 */
      getList_costcenter() {
        this.costcenter.loading = true;
        listCostcenter(this.costcenter.queryParams).then(response => {
          this.costcenter.rowList = this.handleTree(response.data, "number", "parentnumber");
          this.costcenter.loading = false;
        });
      },
      /** 成本中心搜索按钮操作 */
      handleQuery_costcenter() {
        this.getList_costcenter();
      },
      /** 成本中心重置按钮操作 */
      resetQuery_costcenter() {
        this.resetForm("querycostcenterForm");
        this.handleQuery_costcenter();
      },
      /** 成本中心监听row-click事件，实现选中 */
      rowClick_costcenter(row, column, event) {
        let refsElTable = this.$refs.costcenterTable; // 获取表格对象
        refsElTable.toggleRowSelection(row);  //如过重复选中，则取消选中
      },
      /** 成本中心监听双击事件，实现推送当前行*/
      rowDoubleClick_costcenter(row, column, event) {
        let refsElTable = this.$refs.costcenterTable; // 获取表格对象
        refsElTable.clearSelection(); //清空表格选中数据
        refsElTable.toggleRowSelection(row);  //选中当前行，如过重复选中，则取消选中
        this.toParentPage_costcenter(); //调用推送方法
      },
      /** 展开/折叠操作 */
      toggleExpandAll_costcenter() {
        this.costcenter.refreshTable = false;
        this.costcenter.isExpandAll = !this.costcenter.isExpandAll;
        this.$nextTick(() => {
          this.costcenter.refreshTable = true;
        });
      },
      /**  成本中心多选框选中数据*/
      handleSelectionChange_costcenter(selection) {
        this.costcenter.selectedrowList = selection;
        this.transData.costcenter = this.costcenter.selectedrowList[0]
      },
      /** 成本中心向父页面传输数据 */
      toParentPage_costcenter() {
        if (this.costcenter.selectedrowList.length > 1) {
          this.$modal.msgError("只能选中一条数据！")
          return;
        }
        this.costcenter.show = false;
        let tempdata = this.transData
        this.$emit('emitToParent', tempdata);
      },
    },

  }
</script>

<style scoped>

</style>
